﻿using System.Collections.Generic;
using NUnit.Framework;
using StringExtensions;

namespace StringToDictionaryConverterTests
{
 [TestFixture]
  public class UnacceptableSyntax
  {
    [Test, ExpectedException(typeof(System.Exception), ExpectedMessage = "Number of items not 2 (current:3)")]
    public void MissingSemicolon()
    {
      const string sut = "a=b=2";
      var result = sut.ToDictionary();
    }

    [Test, ExpectedException(typeof(System.ArgumentException), ExpectedMessage = "An item with the same key has already been added.")]
    public void KeyOccuresTwice()
    {
      const string sut = "a=1;a=11";
      var result = sut.ToDictionary();
    }

    [Test, ExpectedException(typeof(System.Exception), ExpectedMessage = "Number of items not 2 (current:1)")]
    public void SemicolonAtEndOfString()
    {
      const string sut = "a=1;";
      var result = sut.ToDictionary();
    }

    [Test, ExpectedException(typeof(System.Exception), ExpectedMessage = "Number of items not 2 (current:1)")]
    public void SemicolonAtBeginOfString()
    {
      const string sut = ";a=1";
      var result = sut.ToDictionary();
    }

    [Test, ExpectedException(typeof(System.Exception), ExpectedMessage = "Number of items not 2 (current:1)")]
    public void OnlyOneSemicolon()
    {
      const string sut = ";";
      var result = sut.ToDictionary();
    }

    [Test, ExpectedException(typeof(System.Exception), ExpectedMessage = "Number of items not 2 (current:1)")]
    public void EmptyString()
    {
      const string sut = "";
      var result = sut.ToDictionary();
    }

  }
}
